package com.imageprocess;

import com.imageprocess.demo.WaterView;
import com.imageprocess.tools.ImageHelper;
import com.imageprocess.ui.BitmapView;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class MainActivity extends Activity {
    private WaterView bitmapView = null;
    private ImageView im;
    private Bitmap bmp;

    /**
     * @see android.app.Activity#onCreate(Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);// 去掉信息栏
        // bitmapView = new WaterView(this);
        // this.setContentView(bitmapView);
        BitmapFactory.Options option=new BitmapFactory.Options();
        option.inPreferredConfig=Config.ARGB_8888;
        bmp = (BitmapFactory.decodeResource(this.getResources(),
                R.drawable.demopng,option));
        im = new ImageView(this);
        
        im.setImageBitmap(bmp);
        this.setContentView(im);
    }
    static {
        System.loadLibrary("ImageProcessing");
    }
    public static native void renderBmp(Bitmap  bitmap);
    public boolean onKeyUp(int keyCode, KeyEvent event) {
       // ImageHelper.colorMatrixEffect1(bmp);
        /*ImageHelper.*/
        Bitmap bitmapGray = Bitmap.createBitmap(bmp.getWidth(),bmp.getHeight(),Config.ARGB_8888);
        renderBmp(bitmapGray);
        im.setImageBitmap(bitmapGray);
        return true;
        // return bitmapView.onKeyUp(keyCode,event);
    }
}
